<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateMotionCaptureDataRelationTable extends AbstractMigration
{
    public function up()
    {
        $this->table('motion_capture_data_relation', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '动捕数据关联'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('motion_capture_data_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '动捕数据id'])
            ->addColumn('entity_id', 'integer', ['limit' => 11, 'default' => 0, 'signed' => false, 'comment' => '实体id'])
            ->addColumn('department_id', 'integer', ['limit' => 11, 'default' => 0, 'signed' => false, 'comment' => '部门id'])
            ->addColumn('actor', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '演员'])
            ->addColumn('file', 'text', ['null' => true, 'comment' => '文件'])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间',])
            ->addColumn('created_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建人',])
            ->addColumn('updated', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新时间',])
            ->addColumn('updated_by', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '更新人',])
            ->addIndex(['motion_capture_data_id', 'entity_id'], ['name' => 'idx_unique_motion_capture_data_id_entity_id', 'type' => 'unique'])
            ->save();
    }

    public function down()
    {
        $this->table('motion_capture_data_relation')->drop()->save();
    }
}
